UNDO in dxl

I am currently working on some code that is required to update a number of object attributes as part of a single operation. However, the object state will potentially be inconsistent unless ALL attributes are successfully updated. Therefore, I wish to perform this as a 'transaction' whereby the changes will only be committed if all operations succeed and will be rolled back otherwise.

I have not thus far found a way of performing such a transaction in dxl. A potential solution is to make the module shareable and then lock the object, perform the update and unlockSaveSection/unlockDiscardSection as appropriate. However, there are other reasons why it is preferable to have the module in exclusive edit mode.

I notice that, when I run my code and update multiple attributes, using 'ctrl-z' undoes all of the changes to an object in a single operation despite the history potentially showing a separate entry for the modification of each attribute (depending on whether the operation actually modified the current setting of each attribute).

Does anyone know how to duplicate this ctrl-z behaviour in dxl?
SystemAdmin - Mon Nov 22 06:13:39 EST 2010

Re: UNDO in dxl
SystemAdmin - Mon Nov 22 08:28:37 EST 2010

There is an "undo" function in DXL (ref http://www.smartdxl.com/downloads/undoc31.html) but on testing I could not get it to work.

But you can call the DOORS menu functions with the callStdItem_ (undocumented) function and there is a menu item "undoItem" (documented), so to do in DXL the same action as Edit / Undo (Ctrl-Z) use "callStdItem_ undoItem" - note if no changes are available to undo it returns an error message, so you might want to use noError / lastError around this call.

Other way to implement this would be to store per object all the attributes to be changed and their values before the change to a skip list, then try to do the change and if not successful then roll back using the data in the skip list. This might be better, because the above undo method rolls back everything in the undo stack, even though the change might not have come from your script.

Re: UNDO in dxl
Bob_Swan - Tue Nov 23 03:10:38 EST 2010

Depending on what you want to do if the updates fail, you could simply save the file before starting the updates, then if it fails just close without saving, or save again on completion.
Does make continuation of the dxl more problematic if you have a fail.

Re: UNDO in dxl
SystemAdmin - Tue Nov 23 06:18:20 EST 2010

Thanks for the replies... I will investigate these ideas further...

Re: UNDO in dxl
llandale - Tue Nov 23 14:12:50 EST 2010

Don't know. Here's all the 'undo' stuff from the doors.exe:

These constants seem to be what 'clipLastOp()' returns:
int Clear
int Undo
int Paste
int Copy
int Cut
int clipLastOp()

string clipClear()
string clipClear(bool)
string *clipUndo*()
string clipPasteAndUpdateReferences(Folder)
string clipPaste(Folder)
string clipCopy(Item)
string clipCut(Item)
void undoMarkUp(Object o)
Object markUp(Object o,int firstchar,lastchar)

bool undo(History h,Module m)

'Standard Items' avaialable when making menues:
redoItem undoItemUndelete undoItemDelete undoItemModify undoItemCut undoItem

  • Louie